
package com.tideit.husai.ui.battle

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.tideit.husai.R
import com.tideit.husai.databinding.FragmentBattleStatusBinding

class BattleStatusFragment : Fragment() {
    private var _binding: FragmentBattleStatusBinding? = null
    private val binding get() = _binding!!

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        _binding = FragmentBattleStatusBinding.inflate(inflater, container, false)
        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        
        // 模拟数据更新
        updateBattleData()
    }

    private fun updateBattleData() {
        // 这里应该是从服务器获取实时数据
        // 目前使用模拟数据
        
        binding.tvSunkShips.text = "${(3..5).random()}艘"
        binding.tvAmmoUsed.text = "${(100..150).random()}吨"
        binding.tvOurLosses.text = "${(0..3).random()}架无人机"
        binding.tvAmmoLeft.text = "${(800..900).random()}吨"
        
        val time = java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
            .format(java.util.Date())
        binding.tvUpdateTime.text = "最后更新: $time"
    }

    override fun onDestroyView() {
        super.onDestroyView()
        _binding = null
    }
}
